<template>
	<view>
		<view class="header u-flex">
			<text class="cancel" @click="close">取消</text>
			<view class="u-flex-1"></view>
			<text class="confirm" @click="confirm">确定</text>
		</view>
		<u-cell-group class="u-m-b-20">
			<u-cell-item :title="res.number" v-for="(res, index) in list" :key="res.id" :use-label-slot="true" :arrow="false" @click="choose(res)">
				<view slot="label" @click.stop="goDetails(res.id)">
					<text>{{res.address.name}}</text>
					<text class="u-p-l-10">{{res.address.mobile}}</text>
					<u-alert-tips v-if="res.remarks != ''" class="u-m-t-10" type="info" :description="'备注：'+res.remarks"></u-alert-tips>
				</view>
				<view slot="right-icon">
					<u-checkbox :value="res.checked"></u-checkbox>
				</view>
				<!-- <text>{{res.managestate}}</text> -->
			</u-cell-item>
		</u-cell-group>
		<u-loadmore :status="loadStatus"></u-loadmore>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				loadStatus: 'loading',
				PageIndex: 1,
				PageSize: 50
			}
		},
		created() {
			//5状态为已回收
			this.getOrderList(6)
		},
		methods: {
			// 页面数据
			getOrderList(idx) {
				this.loadStatus = "loading"
			
				return this.$u.post('/User/Order/List', {
					"PageIndex": this.PageIndex,
					"PageSize": this.PageSize,
					"key": '',
					"manageState": idx
					// "Order": [{column:'Sort', isdesc: true}, {column:'Id', isdesc: true}],
					// "assignmentState": 0,
					// "state": 0,
					// "manageState": 0
				}).then((res) => {
					if (res.rows.length > 0) {
						res.rows.forEach((item) => {
							item.checked = false
							this.list.push(item)
						})
						if (res.rows.length < this.PageSize) {
							this.loadStatus = "nomore"
						} else {
							this.loadStatus = "loadmore"
						}
					} else {
						this.loadStatus = "nomore"
					}
					return res.rows
				})
			},
			// 选择已回收订单
			choose(item){
				item.checked = !item.checked
			},
			// 确定选择订单返回
			confirm(){
				let arr = this.list.filter(item=>item.checked)
				this.$emit('confirm',arr)
			},
			// 关闭窗口
			close(){
				this.$emit('close',false)
			},
			goDetails(id){
				uni.navigateTo({
					url: '/pages/brother/order/views/views?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header{
		height: 100rpx;
		padding: 0 30rpx;
		position: sticky;
		top: 0;
		z-index: 99;
		background: #fff;
		box-shadow: 0 0 12px #f6f6f6;
		.cancel{
			
		}
		.confirm{
			color: $u-color-main;
		}
	}
</style>
